const Base = require('./base');

module.exports = class extends Base {
  async byPassAction() {
    const userName = this.post('userName');
    const passWord = this.post('passWord');
    const challenge = this.post('geetest_challenge');
    const validate = this.post('geetest_validate');
    const seccode = this.post('geetest_seccode');
    const captchaRes = await this.service('public/geetestService').validate(challenge,validate,seccode);
    if (!captchaRes) {
      return this.fail('请先进行行为验证');
    }
    const userInfo = await this.service('public/loginService').checkLogin(userName, passWord);
    if (userInfo.status) {
      return this.success(userInfo.data);
    }else{
      return this.fail(userInfo.msg);
    }
  }
  
  async logoutAction() {
    return this.success();
  }
}